package com.wlscale.roadsystem.modular.setting.syscalibration.adapter;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.support.v13.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.wlscale.roadsystem.R;

import java.util.ArrayList;
import java.util.List;

public class SystemCalibrationTablePageAdapter extends FragmentPagerAdapter {
    /**
     * 上下文
     */
    private Context mContext;
    /**
     * Fragment
     */
    private List<Fragment> fragments = new ArrayList<>();
    /**
     * @param fm
     * @deprecated
     */
    public SystemCalibrationTablePageAdapter(Context pContext, FragmentManager fm) {
        super(fm);
        this.mContext = pContext;
    }
    public void addTab(Fragment fragment) {
        fragments.add(fragment);
    }
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
    public View getTabView(Context mContext, String titleName) {
        View tabView = LayoutInflater.from(mContext).inflate(R.layout.item_tab_layout, null);
        TextView tabTitle = tabView.findViewById(R.id.tv_tab_title);
        tabTitle.setText(titleName);
        return tabView;
    }
}
